using System;
using System.Drawing;
using System.Windows.Forms;
using Nuwanda.TfsSpotlight.Shell.Services.Interfaces;
using StructureMap;

namespace Nuwanda.TfsSpotlight.Shell.Services
{
    [Pluggable("ClipboardService")]
    public class ClipboardService : IClipboardService
    {
        /// <summary>Puts given <paramref name="content"/> into the system clipboard</summary>
        /// <param name="content">Content to put.</param>
        public void SetText(string content)
        {
            try
            {
                Clipboard.SetText(content);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Cannot put content to clipboard.", e);
            }
        }

        /// <summary>Puts a given <paramref name="image"/> into the system clipboard.</summary>
        /// <param name="image">An image to put.</param>
        public void SetImage(Image image)
        {
            try
            {
                Clipboard.SetImage(image);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Cannot put content to clipboard.", e);
            }
        }

        public string GetText()
        {
            try
            {
                return Clipboard.GetText();
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Cannot get content from clipboard.", e);
            }
        }
    }
}